package com.ph.irp.base.currency.service.impl;

import java.util.List;

import com.ph.irp.base.currency.dao.PBaseCurrencyDAO;
import com.ph.irp.base.currency.service.CurrencyService;
import com.ph.irp.model.PBaseCurrency;

public class CurrencyServiceImpl implements CurrencyService {

	PBaseCurrencyDAO currencyDaoProxy;

	public PBaseCurrencyDAO getCurrencyDaoProxy() {
		return currencyDaoProxy;
	}

	public void setCurrencyDaoProxy(PBaseCurrencyDAO currencyDaoProxy) {
		this.currencyDaoProxy = currencyDaoProxy;
	}

	/*
	 * 条件查询币别
	 */
	@Override
	public List<PBaseCurrency> getCurrencyAllList(PBaseCurrency currencyModel)
			throws Throwable {
		// TODO Auto-generated method stub

		// 查询代码和名称都不为空的时候
		if (currencyModel == null) {
			return currencyDaoProxy.getAllCurrencyList();
		} else if (!currencyModel.getCurrencyCode().equals("")
				&& !currencyModel.getCurrencyName().equals("")) {

			return currencyDaoProxy.getCurrencyByCodeAndName(currencyModel
					.getCurrencyCode(), currencyModel.getCurrencyName());

		} else {
			// 查询代码或者名称的单个条件
			if (!currencyModel.getCurrencyCode().equals("")) {

				return currencyDaoProxy.getCurrencyByCode(currencyModel
						.getCurrencyCode());

			} else if (!currencyModel.getCurrencyName().equals("")) {

				return currencyDaoProxy.getCurrencyByName(currencyModel
						.getCurrencyName());

			} else {
				return currencyDaoProxy.getAllCurrencyList();
			}
		}
	}

	/*
	 * 查询币别记录实现
	 */
	@Override
	public List<PBaseCurrency> getCurrencyList() throws Throwable {
		// TODO Auto-generated method stub

		return currencyDaoProxy.getAllCurrencyList();
	}

	/*
	 * 添加币别记录实现
	 */
	@Override
	public void addCurrency(PBaseCurrency currencyModel) throws Throwable {
		// TODO Auto-generated method stub
		currencyDaoProxy.addCurrency(currencyModel);
	}

	/*
	 * 根据币别ID查询
	 */
	@Override
	public PBaseCurrency getCurrencyByID(Integer currencyId) throws Throwable {
		return currencyDaoProxy.getCurrencyByID(currencyId);
	}

	/*
	 * 按照币别代码查询
	 */
	@Override
	public List<PBaseCurrency> getCurrencyByCode(String currencyCode)
			throws Throwable {
		return currencyDaoProxy.getCurrencyByCode(currencyCode);
	}

	/*
	 * 按照币别名称和代码一起查询
	 */
	@Override
	public List<PBaseCurrency> getCurrencyByCodeAndName(String currencyCode,
			String currencyName) throws Throwable {
		return currencyDaoProxy.getCurrencyByCodeAndName(currencyCode,
				currencyName);
	}

	/*
	 * 按照币别名称查询
	 */
	@Override
	public List<PBaseCurrency> getCurrencyByName(String currencyName)
			throws Throwable {
		return currencyDaoProxy.getCurrencyByName(currencyName);
	}

	/*
	 * 更新币别记录
	 */
	@Override
	public void updateCurrency(PBaseCurrency currencyModel) throws Throwable {
		currencyDaoProxy.updateCurrency(currencyModel);
	}

	/*
	 * 删除记录
	 */
	@Override
	public void delectCurrency(Integer currencyId) throws Throwable {
		currencyDaoProxy.delectCurrency(currencyId);
	}
}
